<template>
	<view class="info">
		<rich-text :nodes="nodes"></rich-text>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				nodes: '',
				id: '',
				type: '',
			}
		},
		onLoad(e) {
			if(e.id) {
				this.id = e.id;
			}
			if(e.type == 1) {
				this.type = e.type;
				uni.setNavigationBarTitle({
					title: '协议及隐私'
				});
			}
		},
		onShow() {
			if(this.id) {
				this.getInfo();
			}
			if(this.type == 1) {
				this.getDetail();
			}
		},
		methods: {
			async getInfo() {
				const res = await this.$api.get('ebBase/courseDetails', { id: this.id });
				if (res.code == 200) {
					var str = res.data.details;
					str = str.replace(/wscnph/g, 'wscnph maxImg');
					str = str.replace(/<img/g, '<img style="max-width:100% !important;height:auto;"');
					this.nodes = str;
				}
			},
			async getDetail() {
				const res = await this.$api.get('agreement/detail');
				if (res.code == 200) {
					var str = res.data.content;
					str = str.replace(/wscnph/g, 'wscnph maxImg');
					str = str.replace(/<img/g, '<img style="max-width:100% !important;height:auto;"');
					this.nodes = str;
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	p {
		text-indent: 2em;
	}
	.maxImg {
		width: 100%;
		max-width:100% !important;
		height:auto;
	}
	.info {
		padding: 20rpx 27rpx;
		font-size: 28rpx;
	}
</style>